<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Object.defineProperties</title>
</head>
<body>
    <script>
        // defineProperties
        //define 定义
        //Properties 属性
        //为对象添加或修改属性
        var star = {
            firstName:'刘',
            lastName:'德华'
        }

        var obj = Object.defineProperties(star,{
            fullName:{
                get:function(){
                    return this.firstName + this.lastName;
                },
                set:function(name){
                    // console.log(name);
                    // 按照 - 将名字拆分成数组
                    var arr = name.split('-');
                    // console.log(arr);
                    
                    this.firstName = arr[0];
                    this.lastName = arr[1];
                }
            }
        })
        // 引用数据类型和 基本数据类型的区别
        // 1. 基本数据类型是 值的操作
        // 2. 引用数据类型是地址的操作

        // console.log(obj,star, obj===star);
        console.log(star.fullName);

        star.fullName = '陈-奕迅';
        console.log(star.fullName);


    </script>
</body>
</html>